{{- define "title" -}}
  {{- .Title }} - {{ T .Data.Singular | default .Data.Singular -}}
  {{- if .Site.Params.withSiteTitle }} {{ .Site.Params.titleDelimiter }} {{ .Site.Title }}{{- end -}}
{{- end -}}

{{- define "content" -}}
  <div class="page archive">
    {{- /* Title */ -}}
    {{- $taxonomy := .Data.Singular -}}
    {{- $pageCount := len .Pages -}}
    {{- $termIcon := "" -}}
    {{- $termTitle := .Title -}}
    {{- if eq $taxonomy "category" -}}
      {{- $termIcon = "fa-regular fa-folder-open" -}}
    {{- else if eq $taxonomy "tag" -}}
      {{- $termIcon = "fa-solid fa-tag" -}}
    {{- else if eq $taxonomy "collection" -}}
      {{- $termIcon = "fa-solid fa-layer-group" -}}
    {{- else -}}
      {{- $termTitle = printf "%v - %v" (T $taxonomy | default $taxonomy) .Title -}}
    {{- end -}}
    <h1 class="single-title animate__animated animate__pulse animate__faster">
      {{- with $termIcon -}}
        {{- dict "Class" (add . " fa-fw me-1") | partial "plugin/icon.html" -}}
      {{- end -}}
      {{- $termTitle }} <sup>{{ $pageCount }}</sup>
    </h1>

    {{- /* Paginate */ -}}
    {{- if .Pages -}}
      {{- $pages := .Pages.GroupByDate "2006" -}}
      {{- with .Site.Params.list.paginate | default .Site.Params.paginate -}}
        {{- $pages = $.Paginate $pages . -}}
      {{- else -}}
        {{- $pages = .Paginate $pages -}}
      {{- end -}}
      {{- range $pages.PageGroups -}}
        <h2 class="group-title">
          {{- dict "Class" "fa-regular fa-calendar fa-fw me-1" | partial "plugin/icon.html" -}}
          {{- .Key -}}
        </h2>
        {{- range .Pages -}}
          <article class="archive-item">
            <a href="{{ .RelPermalink }}" class="archive-item-link">
              {{- $repost := .Params.repost | default dict -}}
              {{- if eq $repost.enable true -}}
                {{- dict "Class" "fa-solid fa-share fa-fw text-success me-1" | partial "plugin/icon.html" -}}
              {{- end -}}
              {{- title .LinkTitle -}}
            </a>
            <span class="archive-item-date" title='{{ "2006-01-02 15:04:05" | .Date.Format }}'>
              {{- .Date | dateFormat ($.Site.Params.list.dateFormat | default "01-02") -}}
            </span>
          </article>
        {{- end -}}
      {{- end -}}
      {{- partial "paginator.html" . -}}
    {{- end -}}
  </div>
{{- end -}}
